//
//  MineMessageTableViewController.m
//  MJApp
//
//  Created by wangliang on 15/3/30.
//  Copyright (c) 2015年 wangliang. All rights reserved.
//

#import "MineMessageTableViewController.h"
#import "MineCellTableViewCell.h"
#import "MineShareTableViewController.h"
#import "MineActiveTableViewController.h"
#import "MineRainViewController.h"
#import "PrivateLetterViewController.h"
#import "MineAllRainViewController.h"

@interface MineMessageTableViewController ()
@property(nonatomic,strong)NSMutableArray *tableViewArray;
@property(nonatomic,strong)NSDictionary *infoDic;
@end

@implementation MineMessageTableViewController

- (NSMutableArray *)tableViewArray {
    
    if (!_tableViewArray) {
        
        _tableViewArray = [NSMutableArray array];
    }
    return _tableViewArray;
}

- (instancetype)initWithDic:(NSDictionary *)dic {
    
    if (self = [super init]) {
        
        self.infoDic = dic;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self Data];
    [self UI];
}

- (void)Data {
    
    NSArray *nameArray = @[@"活动",@"分享",@"私信",@"评论"];
    NSArray *imageArray = @[@"grzx8_08.png",@"grzx8_10.png",@"grzx8_03.png",@"grzx8_06.png"];
    NSArray *numArray = @[self.infoDic[@"activity_count"],@"0",self.infoDic[@"message_count"],self.infoDic[@"discuss_count"]];
    for (int i = 0; i < nameArray.count; i ++) {
        
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        dic[@"name"] = nameArray[i];
        dic[@"imagestr"] = imageArray[i];
        dic[@"num"] = numArray[i];
        [self.tableViewArray addObject:dic];
    }
}

- (void)UI {
    
    [((TabBarController *)self.tabBarController) setTabbarHidden:YES];
    self.title = @"消息中心";
    self.tableView.backgroundColor = Color_Back_Black;
    self.tableView.separatorColor = [UIColor clearColor];
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    MineCellTableViewCell *cell = (MineCellTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.cellHigh;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   
    MineCellTableViewCell * cell = [MineCellTableViewCell initWithTableView:tableView];
    cell.infoDic = self.tableViewArray[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 1) {
        
        [self.navigationController pushViewController:[[MineShareTableViewController alloc] init] animated:YES];
    }else if (indexPath.row == 0) {
        
        [self.navigationController pushViewController:[[MineActiveTableViewController alloc] init] animated:YES];
    }else if (indexPath.row == 3) {
        
        [self.navigationController pushViewController:[[MineAllRainViewController alloc] init] animated:YES];
    }else if (indexPath.row == 2) {
        
        [self.navigationController pushViewController:[[PrivateLetterViewController alloc] init] animated:YES];
    }
}


@end
